/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.admin.controller;

import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.pinyin.PinyinUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tenant.annotation.TenantIgnore;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.admin.entity.Building;
import org.springblade.modules.admin.entity.Elevator;
import org.springblade.modules.admin.entity.MaintainScoreTemplate;
import org.springblade.modules.admin.mapper.es.ProjectDocumentMapper;
import org.springblade.modules.admin.service.BuildingService;
import org.springblade.modules.admin.service.ElevatorService;
import org.springblade.modules.admin.service.MaintainScoreTemplateService;
import org.springblade.modules.admin.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Date 16:22 2024/1/5
 * @Description {
 *   评分模板
 * }
 * @Author lsay
 **/
@RestController
@RequestMapping("/score/template")
@Api(value = "评分模板", tags = "评分模板接口")
public class ScoreTemplateController {

	@Autowired
	private MaintainScoreTemplateService scoreTemplateService;

	/**
	 * @Author lsay
	 * @Description {
	 *   查询评分模板列表
	 * }
	 * @Date 16:36 2024/1/5
	 * @Param
	 * @return 评分模板列表
	 **/
	@GetMapping("/list")
	public R<List<MaintainScoreTemplate>> list(Integer planType){
		return R.data(scoreTemplateService.list(Wrappers.<MaintainScoreTemplate>lambdaQuery().eq(MaintainScoreTemplate::getPlanType,planType)));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   查询评分模板详情
	 * }
	 * @Date 16:36 2024/1/5
	 * @Param
	 * @return 评分模板详情
	 **/
	@GetMapping("/detail")
	public R<MaintainScoreTemplate> detail(Long id){
		return R.data(scoreTemplateService.detail(id));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   新增或修改评分模板
	 * }
	 * @Date 16:36 2024/1/5
	 * @Param
	 * @return
	 **/
	@PostMapping("/submit")
	public R<Boolean> submit(@RequestBody MaintainScoreTemplate entity){
		return R.data(scoreTemplateService.submit(entity));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   删除评分模板
	 * }
	 * @Date 16:36 2024/1/5
	 * @Param
	 * @return
	 **/
	@DeleteMapping("/remove")
	public R<Boolean> remove(String ids){
		return R.data(scoreTemplateService.removeByIds(Func.toLongList(ids)));
	}

}
